<?php

class Emailgroup_model extends CI_Model{

	function getall_emailgroups()
	{
		$this->db->from('tbl_emailgroups');
		$this->db->order_by("group_id", "asc"); 
		return $this->db->get();
	}
	
	function getall_users()
	{
		$this->db->from('users');
		$this->db->order_by("id", "asc"); 
		return $this->db->get();
	}
	
	function emailgroup_insert($post) {
	
		$this->db->insert('tbl_emailgroups',$post);
		$result = $this->db->insert_id();
		return $result;
	}
	
	function emailgroup_record($group_id) {
		return $this->db->where_in('group_id',$group_id)->limit(1)->get('tbl_emailgroups')->row_array();	
	}
	
	function emailgroup_update_record($groupemailinfo,$group_id) {
	
		 $this->db->where('group_id',$group_id);			
		 $rec = $this->db->update('tbl_emailgroups',$groupemailinfo);
		 return $rec;		 
	}
	
	function emailgroup_delete($id)  {
		$delete_store = $this->db->query('delete from tbl_emailgroups WHERE `group_id`='.$id);		
		return TRUE;
	}	

}